<?php
/**
 * 标签管理模块
 * @copyright reginx.com
 * $Id: tag.mod.php 138 2013-01-09 09:29:53Z reginx.com@gmail.com $
 */
class tag_mod extends admin_mod {
    
    /**
     * 标签类别 ID
     *
     * @var unknown_type
     */
    private $ctype = 0;
    
    /**
     * tag tab object
     *
     * @var unknown_type
     */
    private $obj   = null;
    
    /**
     * 架构函数
     *
     * @param unknown_type $param
     */
    public function __construct($param){
        parent::__construct($param);
        $this->obj = core::getobj('tag_tab');
        $this->ctype = intval($this->get('ctype' , 'R'));
    }
    
    /**
     * 标签列表页
     *
     */
    public function listAct(){
        $this->assign('atitle' , '标签列表');
        $pobj = new page_lib($this->obj->count() , 'pn' , intval($this->get('pn')) , 20 , 'desc' , 3);
        $this->assign('pobj' , $pobj->toarray());
        $this->assign('tags' , core::getobj('tag_tab')->order("sort {$pobj->desc} , id {$pobj->desc}")->limit($pobj->limit)->getall());
        $this->display('tag/list.html');
    }
    
    /**
     * Tag 删除
     *
     */
    public function delAct(){
        $id = intval($this->get('id'));
        $this->obj->where("id = {$id}")->del();
        $this->showmsg('操作成功' , null , 1 , 1);
    }
    
    /**
     * 获取tag
     *
     */
    public function getAct(){
        $code = $this->has('code') ? strtolower($this->get('code' , 'R')) : 'A';
        $this->assign('cb' , $this->get('cb' , 'R'));
        $this->assign('ctype' , $this->ctype);
        $this->assign('code' , strtoupper($code));
        $this->assign('tags' , $this->obj->where("ctype = {$this->ctype} and pyh = '{$code}'")->order("sort desc")->getall());
        $this->display('tag/get.html');
    }
    
    public function addAct(){
        //tag_lib::add(1 , 16 , '杰克,aivre,山姆');
    }
    
}
?>